﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel.DomainServices.Server;
using System.Collections.ObjectModel;
using NetBay.Core.BusinessEntities;
using Rio.Framework.Business.Repository;
using NetBay.Core.BusinessEntities.DashBoard;
using Rio.Manager.Business.Repository;

namespace Rio.Applications.Web.Services
{
    public partial class BusinessEntitiesDomainService : DomainService
    {
        /// <summary>
        /// Get a numerization resum for each operator
        /// </summary>
        /// <returns></returns>
        [Invoke(HasSideEffects = true)]
        public IEnumerable<NumerizationOperator> GetNumerizationReportByOperator(DateTime StartDate, DateTime EndDate)
        {
            var l_oRet = new List<NumerizationOperator>();
            try
            {
                NetBay.Core.Log.LogManager.Instance().LogDebug("(StartDate<" + StartDate.ToString() + "> EndDate<" + EndDate.ToString() + ">)...");
                l_oRet = DashBoardRepository.GetNumerizationReportByOperator(StartDate, EndDate);
            }
            catch (Exception ex)
            {
                NetBay.Core.Log.LogManager.Instance().LogError("Exception in GetNumerizationResumByOperator : " + ex.Message);
            }
            return l_oRet;
        }

        /// <summary>
        /// Get a numerization resum for each operator by date
        /// </summary>
        /// <returns></returns>
        [Invoke(HasSideEffects = true)]
        public IEnumerable<NumerizationFoldersByDate> GetNumerizationFoldersReportByOperatorByDate(long userId, DateTime startDate, DateTime endDate)
        {
            var l_oRet = new List<NumerizationFoldersByDate>();
            try
            {
                NetBay.Core.Log.LogManager.Instance().LogDebug("(UserId<" + userId.ToString() + "> StartDate<" + startDate.ToString() + "> EndDate<" + endDate.ToString() + ">)...");
                l_oRet = NumerizationFoldersByDateRepository.GetNumerizationFoldersByDate(userId, startDate, endDate);
            }
            catch (Exception ex)
            {
                NetBay.Core.Log.LogManager.Instance().LogError("Exception in GetNumerizationFoldersReportByOperatorByDate : " + ex.Message);
            }
            return l_oRet;
        }


        /// <summary>
        /// Get a global numerization resum 
        /// </summary>
        [Invoke(HasSideEffects = true)]
        public IEnumerable<NumerizationResum> GetNumerizationReport(DateTime StartDate, DateTime EndDate)
        {
            var l_oRet = new List<NumerizationResum>();
            try
            {
                NetBay.Core.Log.LogManager.Instance().LogDebug("(StartDate<" + StartDate.ToString() + "> EndDate<" + EndDate.ToString() + ">)...");
                l_oRet.Add(DashBoardRepository.GetNumerizationReport(StartDate, EndDate));
            }
            catch (Exception ex)
            {
                NetBay.Core.Log.LogManager.Instance().LogError("Exception in GetNumerizationResum : " + ex.Message);
            }
            return l_oRet;
        }

    }
}